Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A number of (mostly/all nerd-) fonts have broken paths #40

Closed
6 tasks done
13steinj opened this issue Apr 11, 2024 · 5 comments
Closed
6 tasks done

A number of (mostly/all nerd-) fonts have broken paths #40

13steinj opened this issue Apr 11, 2024 · 5 comments
Assignees

Comments

@13steinj
Copy link

General troubleshooting steps

Description of issue

I stepped away from a linux install in which I have installed many fonts. I have come back, and did a brew update && brew upgrade. I kept running into errors with the font packages. I stepped away again, because I didn't have time to bother debugging.

On a new linux machine, with a fresh-ish homebrew installation-- brew install ont-ubuntu-mono-nerd-font fails. Looking at the zip, the paths of the fonts are wrong.

Example fix for the above mentioned font:

From 8a85a209c2542ad50d8539d171a39a9210359618 Mon Sep 17 00:00:00 2001
From: 13steinj <13steinj@users.noreply.github.com>
Date: Wed, 10 Apr 2024 20:03:54 -0500
Subject: [PATCH] Fix Ubuntu Mono Nerd Font paths

---
 Formula/font-ubuntu-mono-nerd-font.rb | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Formula/font-ubuntu-mono-nerd-font.rb b/Formula/font-ubuntu-mono-nerd-font.rb
index 5cbc1837a..877e30df2 100644
--- a/Formula/font-ubuntu-mono-nerd-font.rb
+++ b/Formula/font-ubuntu-mono-nerd-font.rb
@@ -6,18 +6,18 @@ class FontUbuntuMonoNerdFont < Formula
   desc "Developer targeted fonts with a high number of glyphs"
   homepage "https://github.com/ryanoasis/nerd-fonts"
   def install
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFont-Bold.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFont-BoldItalic.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFont-Italic.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFont-Regular.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFontMono-Bold.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFontMono-BoldItalic.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFontMono-Italic.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFontMono-Regular.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFontPropo-Bold.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFontPropo-BoldItalic.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFontPropo-Italic.ttf"
-    (share/"fonts").install "UbuntuMono/" + "UbuntuMonoNerdFontPropo-Regular.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFont-Bold.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFont-BoldItalic.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFont-Italic.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFont-Regular.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFontMono-Bold.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFontMono-BoldItalic.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFontMono-Italic.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFontMono-Regular.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFontPropo-Bold.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFontPropo-BoldItalic.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFontPropo-Italic.ttf"
+    (share/"fonts").install "UbuntuMonoNerdFontPropo-Regular.ttf"
   end
   # No zap stanza required
 
-- 
2.44.0

It is similarly possible that not all fonts are installed (I haven't checked this zip, nor others).
I'd submit PRs but wanted to make an issue first because:

  • I'd be doing it mostly ad-hoc, and don't want to spam PRs without some green light
  • It's possible the maintainers have an automated generator / fix that I don't know about.

Output of your command with --verbose --debug

==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FromNameLoader): loading font-ubuntu-mono-nerd-font
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FromNameLoader): loading font-ubuntu-mono-nerd-font
==> Fetching homebrew/linux-fonts/font-ubuntu-mono-nerd-font
==> Downloading https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.0/UbuntuMono.zip
/usr/bin/env /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Linuxbrew/4.2.17-47-g2f58aaa\ \(Linux\;\ x86_64\ Ubuntu\ 22.04.4\ LTS\)\ curl/7.81.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.0/UbuntuMono.zip
Already downloaded: /home/steinj13/.cache/Homebrew/downloads/68ec1c8cdf91145f9a3bd2b870c958414ac5aea5aa849f10d49ba13f869e338e--UbuntuMono.zip
==> Verifying checksum for '68ec1c8cdf91145f9a3bd2b870c958414ac5aea5aa849f10d49ba13f869e338e--UbuntuMono.zip'
==> Installing font-ubuntu-mono-nerd-font from homebrew/linux-fonts
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FromTapLoader): loading homebrew/linux-fonts/font-ubuntu-mono-nerd-font
/usr/bin/env /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/shared/git --version
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromPathLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-linux-fonts/Formula/font-ubuntu-mono-nerd-font.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromAPILoader): loading gcc@11
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromAPILoader): loading binutils
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromAPILoader): loading make
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromAPILoader): loading gcc
/usr/bin/env /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/shared/git --version
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromAPILoader): loading gcc@11
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromAPILoader): loading gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromAPILoader): loading gcc@11
/usr/bin/env PATH=/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super:/home/linuxbrew/.linuxbrew/opt/binutils/bin:/usr/bin:/bin:/usr/sbin:/sbin unzip -o /home/steinj13/.cache/Homebrew/downloads/68ec1c8cdf91145f9a3bd2b870c958414ac5aea5aa849f10d49ba13f869e338e--UbuntuMono.zip -d /tmp/homebrew-unpack20240410-1806847-fcb2t4
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFontPropo-BoldItalic.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFontPropo-BoldItalic.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFontMono-Italic.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFontMono-Italic.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFont-Bold.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFont-Bold.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/LICENCE-FAQ.txt /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/LICENCE-FAQ.txt
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFontMono-Regular.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFontMono-Regular.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFontPropo-Bold.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFontPropo-Bold.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFontMono-BoldItalic.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFontMono-BoldItalic.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFontPropo-Regular.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFontPropo-Regular.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/README.md /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/README.md
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFontPropo-Italic.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFontPropo-Italic.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/LICENCE.txt /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/LICENCE.txt
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFontMono-Bold.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFontMono-Bold.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFont-BoldItalic.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFont-BoldItalic.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFont-Regular.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFont-Regular.ttf
/usr/bin/env cp -pR /tmp/homebrew-unpack20240410-1806847-fcb2t4/UbuntuMonoNerdFont-Italic.ttf /tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja/UbuntuMonoNerdFont-Italic.ttf
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'
Errno::ENOENT: No such file or directory - UbuntuMono/UbuntuMonoNerdFont-Bold.ttf
1. raise
2. ignore
3. backtrace
4. irb
5. shell
Choose an action: 1
==> Temporary files retained at:
/tmp/font-ubuntu-mono-nerd-font-20240410-1806847-7zwfja
Error: An exception occurred within a child process:
  Errno::ENOENT: No such file or directory - UbuntuMono/UbuntuMonoNerdFont-Bold.ttf
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/ignorable.rb:28:in `callcc'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/ignorable.rb:28:in `raise'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/pathname.rb:119:in `install_p'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/call_validation.rb:270:in `bind_call'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/call_validation.rb:270:in `validate_call'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:277:in `block in _on_method_added'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/pathname.rb:111:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/pathname.rb:92:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/pathname.rb:92:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/call_validation.rb:270:in `bind_call'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/call_validation.rb:270:in `validate_call'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11338/lib/types/private/methods/_methods.rb:277:in `block in _on_method_added'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-linux-fonts/Formula/font-ubuntu-mono-nerd-font.rb:9:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/debrew.rb:17:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/debrew.rb:88:in `debrew'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/debrew.rb:17:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:179:in `block (3 levels) in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/kernel.rb:495:in `with_env'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:139:in `block (2 levels) in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1418:in `block in brew'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:3000:in `block (2 levels) in stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/kernel.rb:495:in `with_env'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2999:in `block in stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/resource.rb:129:in `block (2 levels) in unpack'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/download_strategy.rb:121:in `chdir'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/download_strategy.rb:113:in `stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/resource.rb:125:in `block in unpack'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/mktemp.rb:75:in `block in run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/mktemp.rb:75:in `chdir'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/mktemp.rb:75:in `run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/resource.rb:226:in `stage_resource'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/resource.rb:124:in `unpack'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/resource.rb:98:in `stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/forwardable.rb:238:in `stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2979:in `stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1411:in `brew'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:133:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/kernel.rb:495:in `with_env'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:125:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:231:in `<main>'

Output of brew cask doctor

Error: `brew cask` is no longer a `brew` command. Use `brew <command> --cask` instead.

lol part 1

┌─[steinj13@colpdev01] - [~] - [Wed Apr 10, 20:15]
└─[$] <> brew doctor --cask
Usage: brew doctor, dr [--list-checks] [--audit-debug] [diagnostic_check ...]

Check your system for potential problems. Will exit with a non-zero status if
any potential problems are found.

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this.

      --list-checks                List all audit methods, which can be run
                                   individually if provided as arguments.
  -D, --audit-debug                Enable debugging and profiling of audit
                                   methods.
  -d, --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.
Error: invalid option: --cask

lol part 2, methinks the template needs some updating ;)

@tani
Copy link
Member

tani commented Apr 11, 2024

Hello, 13steinj.
Thank you for your patience and for reporting the problem about the issue. The issue you have pointed out brings back memories of a similar problem that we had a few years ago and dealt with.

As I'm sure you've experienced, until you unzip a zip file, it's hard to tell whether the contents of the zip file are well organised into a single directory, or just an archive file with several files flattened out.

A few years ago, this problem was encountered in extracting zip files. Therefore, we had to change to such a FORMULA. But today you have pointed out that it is time to change the treatment of similar zip files again.

I know how to fix it. As you have noticed, the auto-generated scripts need to be improved.
The relevant section is

rule(:font => simple(:font)) {
afont = font.to_s
afont = afont.sub(/"(.*\/)/, '"#{parent}\1')
if @@only_path != "" && !afont.include?('#{parent}') then
afont = "\"#{@@only_path}/\" + " + afont
end
afont = replace_cask_version_properties(afont)
"(share/\"fonts\").install #{afont}"
}
.

If you are in a hurry, please fix this and send me a PR. I will be happy to review it. I will also make time over the weekend to fix it.

Thank you very much.

@13steinj
Copy link
Author

Not in a hurry, might not have the time to fix it before you do. Thank you for the prompt response!

@13steinj
Copy link
Author

Could the formula generator be changed to read the entries in the zip file and install those, rather than hard-coding the path transformation?

@13steinj
Copy link
Author

FYI it appears as though this has been fixed with some nerd fonts since my original issue based on commit history; but with at least the reported one, still a problem.

I can pick this up over the weekend if you don't have the time, just say the word! Just don't want to unintentionally step on toes.

@tani tani self-assigned this May 19, 2024
@tani tani closed this as completed in 90889ee May 20, 2024
@tani
Copy link
Member

tani commented May 20, 2024

@13steinj

Thank you for reporting this issue and sharing your insights. The problem with specifying the actual font files in the formula arises due to the nature of zip archives containing font files. Many fonts are distributed as zip files, which can either contain neatly organized directories or have files scattered flatly in the root directory. This inconsistency makes it challenging to specify paths accurately without extracting the zip file first.

To address this, I have implemented a change that uses glob patterns to match the font files, regardless of the directory structure within the zip file. By using glob('**/*.ttf') and similar patterns, we can capture the font files whether they are in the root directory or within subdirectories. This approach reduces the risk of missing fonts due to path specification issues.

However, there is a minor concern that this method might accidentally include font files located in very deep directories. Based on our experience, font distribution files usually do not have such deep directory structures, so this risk is minimal.

Additionally, I have replaced the use of class variables with simple global variables in the implementation. This change aims to reduce bugs and simplify the code. While this approach does not support parallel processing, we plan to implement instance variables in the future to enable parallelism. This will be addressed in future updates.

I hope this solution resolves the issues you've encountered. If there are any further problems or questions, please let me know. Thank you for your understanding and cooperation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants